from mcp.server.fastmcp import FastMCP
import aiofiles  # 异步操作文件


app = FastMCP("resource template mcp")

@app.resource(
    uri="user://{user_id}",
    name="user_detail",
    description="根据参数user_id获取用户的详情信息 \n:param user_id: 用户的id",
    mime_type="application/json"
)
async def user_detail(user_id: str):
    """
    根据用户ID获取用户详情
    :param user_id: 用户的唯一标识ID，字符串类型
    :return: 包含用户ID、用户名、性别、学校的JSON数据
    """
    return {
        "user": {
            "id": user_id,
            "username": "张三",
            "gender": "male",
            "university": "北京大学"
        }
    }

if __name__ == '__main__':
    app.run(transport="sse")